//
//  RequestData.m
//  WorkNest
//
//  Created by qbm360 on 15/7/6.
//  Copyright (c) 2015年 nest. All rights reserved.
//

#import "RequestData.h"

@implementation RequestData

// 登录/
+ (void)loginParameters:(NSDictionary *)params withBlock:(void (^)(UserModel *, NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/userLogin" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if (block) {
                block(nil, [responseObject valueForKeyPath:@"MSG"], error);
            }
        } else {
            NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
            [userDefaults setObject:[responseObject valueForKeyPath:@"token"] forKey:@"userToken"];
            [userDefaults synchronize];
            NSUserDefaults *userDefaults1 = [NSUserDefaults standardUserDefaults];
            [userDefaults1 setObject:[responseObject valueForKeyPath:@"userName"] forKey:@"userName"];
            [userDefaults1 synchronize];
            
            UserModel *userData = [[UserModel alloc] init];
            userData.userName = [responseObject valueForKey:@"userName"];
            userData.userToken = [responseObject valueForKey:@"token"];
//            [UIUtil archiveDataToDefaults:userData withKey:@"userData"];
            if (block) {
                block(userData, [responseObject valueForKeyPath:@"MSG"], nil);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 退出登录/
+ (void)loginoutParameters:(NSDictionary *)params withBlock:(void (^)(NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/userLogout" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"], error);
            }
        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"], nil);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

// 注册/
+ (void)registParameters:(NSDictionary *)params withBlock:(void (^)(UserModel *, NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/register" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if (block) {
                block(nil, [responseObject valueForKeyPath:@"MSG"], error);
            }
        } else {
            NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
            [userDefaults setObject:[responseObject valueForKeyPath:@"token"] forKey:@"userToken"];
            [userDefaults setObject:[responseObject valueForKeyPath:@"userName"] forKey:@"userName"];
            [userDefaults synchronize];
            UserModel *userData = [[UserModel alloc] init];
            userData.userName = [responseObject valueForKey:@"userName"];
            userData.userToken = [responseObject valueForKey:@"token"];
            [UIUtil archiveDataToDefaults:userData withKey:@"userData"];
            if (block) {
                block(userData, [responseObject valueForKeyPath:@"MSG"], nil);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 获取验证码/
+ (void)getCodeNumber:(NSDictionary *)params withBlock:(void (^)(NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/getAuthCode" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"], error);
            }
        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"], nil);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

// 更改密码/
+ (void)changePassword:(NSDictionary *)params withBlock:(void (^)(NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/forgetPassword" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"],error);
            }
        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

// 修改用户信息
+ (void)updateUserInfo:(NSDictionary *)params withBlock:(void (^)(NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/updateUserInfo" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block([responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block([responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

// 查询用户信息
+ (void)getUserDetail:(NSDictionary *)params withBlock:(void (^)(UserInfoModel *, NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/queryUserDetail" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            UserInfoModel *model = [UserInfoModel objectWithKeyValues:[responseObject valueForKey:@"user"]];
            if (block) {
                block(model,[responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil,nil, error);
        }
    }];
}

// 首页
+ (void)requestProductParameters:(NSDictionary *)params withBlock:(void (^)(NSArray *productModel, NSString *, NSError *error))block {
    [[AFAPIClient sharedClient] POST:@"User/productSelectRecords" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"] || !((NSArray *)[responseObject valueForKey:@"datalist"]).count >0) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"error"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"datalist"]) {
                ProductModel *model = [ProductModel objectWithKeyValues:data];
                [tempArray addObject:model];
            }
            if (block) {
                block(tempArray, [responseObject valueForKeyPath:@"MSG"], error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 查询产品详情
+ (void)getProductDetail:(NSDictionary *)params withBlock:(void (^)(ProductDetailModel *, NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/queryProductDetail" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            ProductDetailModel *model = [ProductDetailModel objectWithKeyValues:responseObject];
            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"datalist"]) {
                [tempArray addObject:[data valueForKey:@"url"]];
            }
            model.imageList = tempArray;
            if (block) {
                block(model,[responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil,nil, error);
        }
    }];
}

// 文件上传
+ (void)fileUploadParameters:(NSDictionary *)params imageData:(UIImage *)imageData withBlock:(void (^)(NSString *, NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/fileUpload" parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
        NSData *data =  UIImageJPEGRepresentation(imageData, 0.6);
        // name跟文档参数是同一个
        [formData appendPartWithFileData:data name:@"fileData" fileName:@"fileData.png" mimeType:@"image/png"];
    } success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"error"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"fileId"], [responseObject valueForKeyPath:@"MSG"], error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            NSLog(@"file");
            block(nil, nil, error);
        }
    }];
}

// 询价
+ (void)priceQueryParameters:(NSDictionary *)params withBlock:(void (^)(NSString *, NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/inquire" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
         if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
             if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                 if (block) {
                     block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                 }
             } else {
                 if (block) {
                     block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                 }
             }
        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"inquireId"], [responseObject valueForKeyPath:@"MSG"], error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 开发
+ (void)developParameters:(NSDictionary *)params withBlock:(void (^)(NSString *, NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/need" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
         if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
             if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                 if (block) {
                     block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                 }
             } else {
                 if (block) {
                     block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                 }
             }
        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"needId"], [responseObject valueForKeyPath:@"MSG"], error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 大货下单
+ (void)bulkorderParameters:(NSDictionary *)params withBlock:(void (^)(NSString *,NSString *, NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/bulkorder" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"bulkOrderId"],[responseObject valueForKeyPath:@"toPayId"],[responseObject valueForKeyPath:@"MSG"], error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil,nil, nil, error);
        }
    }];
}

// 开发单列表
+ (void)developListParameters:(NSDictionary *)params withBlock:(void (^)(NSArray *, NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/queryNeedRecords" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"] || [[responseObject valueForKey:@"total"] integerValue] == 0) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"error"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"needList"]) {
                PriceQueryModel *model = [PriceQueryModel objectWithKeyValues:data];
                [tempArray addObject:model];
            }
            if (block) {
                block(tempArray, [responseObject valueForKeyPath:@"MSG"], error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 询价单列表
+ (void)priceQueryListParameters:(NSDictionary *)params withBlock:(void (^)(NSArray *, NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/queryInquireRecords" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"] || [[responseObject valueForKey:@"total"] integerValue] == 0) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"error"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"inquireList"]) {
                PriceQueryModel *model = [PriceQueryModel objectWithKeyValues:data];
                [tempArray addObject:model];
            }
            if (block) {
                block(tempArray, [responseObject valueForKeyPath:@"MSG"], error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 大货单列表
+ (void)bulkorderListParameters:(NSDictionary *)params withBlock:(void (^)(NSArray *, NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/queryBulkorderRecords" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"error"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            if ([[responseObject valueForKey:@"total"] integerValue] == 0) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"total"],error);
                }
            } else {
                NSMutableArray *tempArray = [[NSMutableArray alloc] init];
                for (NSDictionary *data in [responseObject objectForKey:@"bulkOrderList"]) {
                    BulkorderModel *model = [BulkorderModel objectWithKeyValues:data];
                    [tempArray addObject:model];
                }
                if (block) {
                    block(tempArray, [responseObject valueForKeyPath:@"MSG"], error);
                }
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 待支付列表
+ (void)queryToPayListParameters:(NSDictionary *)params withBlock:(void (^)(NSArray *, NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/queryToPayRecords" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"] || [[responseObject valueForKey:@"total"] integerValue] == 0) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"error"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"dataList"]) {
                PayModel *model = [PayModel objectWithKeyValues:data];
                [tempArray addObject:model];
            }
            if (block) {
                block(tempArray, [responseObject valueForKeyPath:@"MSG"], error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 开发单, 询价单详情
+ (void)developDetailParameters:(NSDictionary *)params url:(NSString *)urlString withBlock:(void (^)(PriceQueryModel *, QueryQuoteModel*, NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:urlString parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"error"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            NSString *string;
            if ([urlString isEqualToString:@"/gckjapi/queryInquireDetail"]) {
                string = @"inquire";
            } else {
                string = @"need";
            }
            PriceQueryModel *priceQueryModel = [PriceQueryModel objectWithKeyValues:[responseObject valueForKey:string]];
            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"imageList"]) {
                [tempArray addObject:[data valueForKey:@"url"]];
            }
            priceQueryModel.imageList = tempArray;
            QueryQuoteModel *queryQuoteModel = [QueryQuoteModel objectWithKeyValues:[responseObject valueForKey:@"quoteList"]];
            if (((NSArray *)[responseObject valueForKey:@"quoteList"]).count>0) {
                queryQuoteModel.quoteId = ((NSArray *)[[responseObject valueForKey:@"quoteList"] valueForKey:@"quoteId"])[0];
            }
            NSMutableArray *tempArray1 = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"imageList"]) {
                [tempArray1 addObject:[data valueForKey:@"url"]];
            }
//            queryQuoteModel.imageList = tempArray;
            if (block) {
                block(priceQueryModel,queryQuoteModel, [responseObject valueForKeyPath:@"MSG"], error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil,nil, nil, error);
        }
    }];
}

// 开发确定样衣
+ (void)needConfirmParameters:(NSDictionary *)params withBlock:(void (^)(NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/needConfirm" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"error"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block([responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block([responseObject valueForKeyPath:@"MSG"],error);
                }
            }        } else {
                if (block) {
                    block([responseObject valueForKeyPath:@"MSG"], error);
                }
            }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

// 询价转开发
+ (void)inquireDevelopParameters:(NSDictionary *)params withBlock:(void (^)(NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/inquireDevelop" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"error"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block([responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block([responseObject valueForKeyPath:@"MSG"],error);
                }
            }        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"], error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

// 报价单详情
+ (void)queryQuoteDetailParameters:(NSDictionary *)params withBlock:(void (^)(QueryQuoteModel *, NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/queryQuoteDetail" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"error"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            QueryQuoteModel *model = [QueryQuoteModel objectWithKeyValues:[responseObject valueForKey:@"quote"]];
//            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
//            for (NSDictionary *data in [responseObject objectForKey:@"imageList"]) {
//                [tempArray addObject:[data valueForKey:@"url"]];
//            }
//            model.imageList = tempArray;
            if (block) {
                block(model, [responseObject valueForKeyPath:@"MSG"], error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 大货单详情
+ (void)bulkorderDetailParameters:(NSDictionary *)params withBlock:(void (^)(BulkorderModel *, NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/queryBulkorderDetail" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"error"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            BulkorderModel *model = [BulkorderModel objectWithKeyValues:[responseObject valueForKey:@"bulkOrder"]];
            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"imageList"]) {
                [tempArray addObject:[data valueForKey:@"url"]];
            }
            NSMutableArray *tempArray1 = [[NSMutableArray alloc] init];
            NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"numList"]) {
                 NSArray *array = @[[data valueForKey:@"color"],[data valueForKey:@"size"],[numberFormatter stringFromNumber:[data valueForKey:@"quantity"]]];
                [tempArray1 addObject:array];
            }
            model.orderId = [[[responseObject objectForKey:@"numList"] valueForKey:@"orderId"] objectAtIndex:0];
            model.imageList = tempArray;
            model.numList = tempArray1;
            if (block) {
                block(model, [responseObject valueForKeyPath:@"MSG"], error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 平台品类
+ (void)CategoryParameters:(NSDictionary *)params url:(NSString *)urlString withBlock:(void (^)(NSArray *, NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:urlString parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"] || [[responseObject valueForKey:@"total"] integerValue] == 0) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"error"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"dataList"]) {
                CategoryModel *model = [CategoryModel objectWithKeyValues:data];
                [tempArray addObject:model];
            }
            if (block) {
                block(tempArray, [responseObject valueForKeyPath:@"MSG"], error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 收货地址更新
+ (void)updateAddress:(NSDictionary *)params withBlock:(void (^)(NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/updateAddress" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block([responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block([responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

// 查询收货地址列表
+ (void)queryAddressList:(NSDictionary *)params withBlock:(void (^)(NSArray *,NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/queryAddressList" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"] || [[responseObject valueForKey:@"total"] integerValue] == 0) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"dataList"]) {
                AddressModel *model = [AddressModel objectWithKeyValues:data];
                [tempArray addObject:model];
            }
            if (block) {
                block(tempArray,[responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 支付信息提交
+ (void)pay:(NSDictionary *)params withBlock:(void (^)(NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/pay" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block([responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block([responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

// 我的账户界⾯（查询支付记录）没写完整
+ (void)selectPayRecords:(NSDictionary *)params withBlock:(void (^)(NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/selectPayRecords" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block([responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block([responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

// 产品收藏
+ (void)productCollect:(NSDictionary *)params withBlock:(void (^)(NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/productCollect" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block([responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block([responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

// 添加购物车
+ (void)addShoppingCart:(NSDictionary *)params withBlock:(void (^)(NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/addShoppingCart" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block([responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block([responseObject valueForKeyPath:@"MSG"],error);
                }
            }        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

// 查询购物车列表
+ (void)queryShoppingCartList:(NSDictionary *)params withBlock:(void (^)(NSArray *,NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/queryShoppingCartList" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"] || [[responseObject valueForKey:@"total"] integerValue] == 0) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"datalist"]) {
                ShoppingCartModel *model = [ShoppingCartModel objectWithKeyValues:data];
                [tempArray addObject:model];
            }
            if (block) {
                block(tempArray,[responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 购物车详情
+ (void)queryShoppingCartParameters:(NSDictionary *)params withBlock:(void (^)(BulkorderModel *, NSString *, NSError*))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/queryShoppingCartRecords" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"error"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            BulkorderModel *bulkorderModel = [BulkorderModel objectWithKeyValues:[responseObject valueForKey:@"bulkOrder"]];
            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"imageList"]) {
                [tempArray addObject:[data valueForKey:@"url"]];
            }
            NSMutableArray *tempArray1 = [[NSMutableArray alloc] init];
            NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
//            for (NSDictionary *data in [responseObject objectForKey:@"numList"]) {
//                NSArray *array = @[@{@"color":[data valueForKey:@"color"],@"size":[data valueForKey:@"size"],@"quantity":[numberFormatter stringFromNumber:[data valueForKey:@"quantity"]]}];
//                [tempArray1 addObject:array];
//            }
            for (NSDictionary *data in [responseObject objectForKey:@"numList"]) {
                NSDictionary *dict = @{@"color":[data valueForKey:@"color"],@"size":[data valueForKey:@"size"],@"quantity":[numberFormatter stringFromNumber:[data valueForKey:@"quantity"]]};
                [tempArray1 addObject:dict];
            }
            bulkorderModel.orderId = [[[responseObject objectForKey:@"numList"] valueForKey:@"orderId"] objectAtIndex:0];
            bulkorderModel.imageList = tempArray;
            bulkorderModel.numList = tempArray1;
            if (block) {
                block(bulkorderModel,[responseObject valueForKeyPath:@"MSG"], error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
    
}

// 查询状态记录
+ (void)queryOrderStatusRecords:(NSDictionary *)params withBlock:(void (^)(NSArray *,NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/queryOrderStatusRecords" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"] || [[responseObject valueForKey:@"total"] integerValue] == 0) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"datalist"]) {
                StatusRecordModel *model = [StatusRecordModel objectWithKeyValues:data];
                [tempArray addObject:model];
            }
            if (block) {
                block(tempArray,[responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 查询交付记录
+ (void)queryDeliveryRecords:(NSDictionary *)params withBlock:(void (^)(NSArray *,NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/queryOrderDeliveryRecords" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"] || [[responseObject valueForKey:@"total"] integerValue] == 0) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else if ([[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]){
                if (block) {
                    block(nil,@"暂无交付记录",error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"datalist"]) {
                StatusRecordModel *model = [StatusRecordModel objectWithKeyValues:data];
                [tempArray addObject:model];
            }
            if (block) {
                block(tempArray,[responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

// 申请推款
+ (void)productApply:(NSDictionary *)params withBlock:(void (^)(NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/productApply" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block([responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block([responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

// 获取推广内容
+ (void)getSendMessage:(NSDictionary *)params withBlock:(void (^)(NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/getSendMessage" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block([responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else {
                if (block) {
                    block([responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            if (block) {
                block([responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

// 我的消息
+ (void)myMessage:(NSDictionary *)params withBlock:(void (^)(NSArray *,NSString *, NSError *))block {
    [[AFAPIClient sharedClient] POST:@"/gckjapi/getMyMessage" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSError *error = nil;
        responseObject = [NSJSONSerialization JSONObjectWithData:responseObject
                                                         options:NSJSONReadingAllowFragments
                                                           error:&error];
        if (![[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"] || [[responseObject valueForKey:@"total"] integerValue] == 0) {
            error = [NSError errorWithDomain:AFAPIBaseURLString code:200 userInfo:[responseObject valueForKeyPath:@"MSG"]];
            if ([[responseObject valueForKey:@"resultCode"] isEqualToString:@"9001"] || [[responseObject valueForKey:@"resultCode"] isEqualToString:@"9002"]) {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"resultCode"],error);
                }
            } else if ([[responseObject valueForKeyPath:@"resultCode"] isEqualToString:@"0"]){
                if (block) {
                    block(nil,@"暂无消息",error);
                }
            } else {
                if (block) {
                    block(nil,[responseObject valueForKeyPath:@"MSG"],error);
                }
            }
        } else {
            NSMutableArray *tempArray = [[NSMutableArray alloc] init];
            for (NSDictionary *data in [responseObject objectForKey:@"message"]) {
                MyMessageModel *model = [[MyMessageModel alloc] init];
                model.mTitle = [data valueForKey:@"title"];
                model.mContent = [data valueForKey:@"content"];
                [tempArray addObject:model];
            }
            if (block) {
                block(tempArray,[responseObject valueForKeyPath:@"MSG"],error);
            }
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, nil, error);
        }
    }];
}

@end
